package com.yd.app.service.pc.shareSrevice;

import com.yd.app.mapper.ShareMapper;
import com.yd.app.service.common.BaseService;
import com.yd.domain.business.Share;
import com.yd.domain.commom.PageModel;
import com.yd.domain.searchParam.ShareParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zy
 * @create 2018-03-12 9:29
 * @desc 分享信息的service
 **/
@Service
public class ShareService extends BaseService{
    @Autowired
    private ShareMapper shareMapper;
    /**
     * @Author: zy
     * @Desc: 录入分享信息
     * @Date:  2018/3/12
     * @Param
     */
    public void addShare(Share share){
        shareMapper.addShare(share);
    }
    /**
     * @Author: zy
     * @Desc: 修改分享信息
     * @Date:  2018/3/12
     * @Param
     */
    public void updateShare(Share share){
        shareMapper.updateShare(share);
    }
    /**
     * @Author: zy
     * @Desc: 删除分享信息
     * @Date:  2018/3/12
     * @Param
     */
    public void deleteShare(String id){
        shareMapper.deleteShare(id);
    }
    /**
     * @Author: zy
     * @Desc: 根据id查询
     * @Date:  2018/3/12
     * @Param
     */
    public Share findById(String id){
        Share share=new Share();
        share=shareMapper.findById(id);
        return share;
    }
    /**
     * @Author: zy
     * @Desc: 审核分享信息状态
     * @Date:  2018/3/12
     * @Param
     */
    public void verifyShare(Share share){
        shareMapper.verifyShare(share);
    }
    /**
     * @Author: zy
     * @Desc: 分页查询数据列表
     * @Date:  2018/3/12
     * @Param
     */
    public PageModel getShareList(ShareParam shareParam, int pageIndex, int pageSize){
        PageModel pm=new PageModel();
        List<Share> list=new ArrayList<>();
        list=shareMapper.searchShareList(shareParam,getStartRow(pageIndex,pageSize),pageSize);
        int count=0;
        if(pageIndex==1){
            //查询总条数
            count=shareMapper.searchShareCount(shareParam);
            pm.setCount(count);
        }
        pm.setList(list);
        return pm;
    }
}
